package com.diors.game.example.server.xmldata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.diors.game.example.server.model.player.model.TestModel;

/**
 * 第二种xml测试
 * @author	darren.ouyang
 * @data	2013-9-16
 */
@XmlRootElement(name = "test_datas")
@XmlAccessorType(XmlAccessType.FIELD)
public class TestFolderData 
{
	
	@XmlElement(name = "test_data")
	private List<TestModel> list;

	private Map<Integer, TestModel> map = new HashMap<Integer, TestModel>();
	
	/**
	 * 加载xml后监听进入
	 * @param u
	 * @param parent
	 * @create	2013-9-16	darren.ouyang
	 */
	void afterUnmarshal(Unmarshaller u, Object parent)
	{
		map.clear();
		for(TestModel model : list)
			map.put(model.getIntValue(), model);
				
		list = null;
		XmlDataManager.log.info("loading TestFolderData size:" + map.size());
	}

	public Map<Integer, TestModel> getMap() {
		return map;
	}
	
}
